@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <a href="/user/checkout_done?month={{$month}}" class="btn btn-primary" type="submit">{{$month}}月 待结算</a>
        <div class="search_box">
            <form id="search_form" method="GET">
                
                <label>
                    Uid：<br>
                    <input type="text" name="uid" value="{{$_search['uid']}}">
                </label>
                <label>
                    推荐码：<br>
                    <input type="text" name="invitation_code" value="{{$_search['invitation_code']}}">
                </label>
                <label>
                    手机号：<br>
                    <input type="text" name="phone" value="{{$_search['phone']}}">
                </label>
                
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>


        </div>
        

        <div id="order_tag"></div>

        <div class="table-responsive">
            @if (count($errors) > 0)
            <div class="alert alert-danger">
                <ul style="color:red;">
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
                </ul>
            </div>
            @endif
            @if (session('success'))
                <div class="alert alert-success">
                    {{ session('success') }}
                </div>
            @endif
            
            <table class="table">
                <caption>已结算列表</caption>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>uid</th>
                        <th>实际到账金额RMB</th>
                        <th>补贴金额数量</th>
                        <th>分成总金额(未结算)</th>
                        <th>分成比例</th>
                        <!--
                        <th>计算完成后分成金额数</th>
                        <th>旗下合伙人带来的50%收益总数</th>
                        -->
                        <th>活跃用户量</th>
                        <th>新增用户量</th>
                        <th>时间</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->id }}</td>
                            <td>{{ $item->uid }}</td>
                            <td>{{ $item->money_all }}</td>
                            <td>{{ $item->subsidy_coin }}</td>
                            <td>{{ $item->divide_into_coin }}</td>
                            <td>{{ $item->proportions }}</td>
                            <!--
                            <td>{{ $item->after_divide_into_coin }}</td>
                            <td>{{ $item->subgrade_coin }}</td>
                            -->

                            <td>{{ $item->active_count }}</td>
                            <td>{{ $item->added_count }}</td>
                            <td>{{ date('Y/m/d', strtotime($item->day)) }}</td>

                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="11">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/theme/ajax_delete_theme/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}

/*
function refund(id){
    if(confirm("确定拒绝吗？")){
        $.post("/cash/ajax_refund/"+id,{},function(json){
            if(json.status==1){
                $("#state_"+id).text("拒绝");
            }else{
                alert(json.info);
            }
        },"json");
    }
}
*/
function refund(id){
    msg=prompt("拒绝备注");
    
    if(msg!=null && msg!=""){
         $.post("/cash/ajax_refund/"+id,{msg:msg},function(json){
            if(json.status==1){
                window.location.reload();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function accept(id){
    if(confirm("确定通过吗？")){
        $.post("/cash/ajax_accept/"+id,{},function(json){
            if(json.status==1){
                $("#state_"+id).text("作弊");
            }else{
                alert(json.info);
            }
        },"json");
    }
}


</script>
@endsection